home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in.0</name>
- <id>-1</id>
- <cardCount>94</cardCount>
- <cardID>6049</cardID>
- <listID>31848</listID>
- <cantModify><false /></cantModify>
- <cantDelete><false /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>512</width>
- <height>342</height>
- </cardSize>
- <script>on openStack
-
- -- set up environment
- -- show msg
- -- palette "Navigator"
- -- show window "Message Watcher"
- -- show window "Variable Watcher"
-
- zeroStack
-
- go to card " Intro1"
- visual effect dissolve slowly
- go to card " intro2"
- visual effect dissolve very slowly
- go to card " intro3"
- visual effect dissolve
- go to first card of bg "Frequencies"
-
- set the highlight of bg button "change radio automatically" to false
-
- InitSerialPort
- end openStack
-
- on closeStack
- closeSerialPort
- pass closeStack
- end closeStack
-
- on idle
- readFromRadio
- LookForErrors
- pass idle
- end idle
-
- on lookForErrors
- if dataWaiting() Γëá false then
- put getfromstack () into line
- if line is "?;" then
- -- put "radio returned an error" into msg
- play "boing"
- else
- addtostack line
- end if
- end if
-
- end lookForErrors
-
-
- -- These functions actually do things with the radio via the
- -- serial port. Should only do it if the radio is defined as
- -- active on the configuration card.
- --
- -- ALL serial port functions should be here.
-
- -- verify radio is configured on.
- function UsingRS232
- return the highlight of cd button "R5000 Attached" of card "Configuration"
- end UsingRS232
-
- -- open and initialize the serial port
- on initSerialPort
- global returnStack
-
- if UsingRS232() = true then
- killSport
- closeSPort
- wait 50
- configureSPort modemPort, autoWrapOff, stripControlsOn, stripOn,¬
- editOff, parityoff, stop20, baud4800, data8, CSTOutON, XOnOutOff, ¬
- linefeedOff,echoOFF
- setSPortbufferSize 10240
- put empty into returnStack
-
- TurnOnRadio
-
- sendToRadio "ID;"
- put false into gotIt
- put 0 into counter
- repeat until gotIt is true
- readFromRadio
- add one to counter
- if counter > 10 then
- answer "Radio is not answering. R5000 disabled." with "OK"
- set the highlight of cd button "R5000 Attached" ¬
- of card "Configuration" to false
- closeSerialPort
- put true into gotIt
- end if
- set cursor to busy
- if dataWaiting () Γëá false then
- put getFromStack () into line
- if line is not "ID005;" then
- answer "Got unknown" & line & "from radio" ¬
- with "Try again" or "Disable"
- if it is "Disable" then
- set the highlight of cd button "R5000 Attached" ¬
- of card "Configuration" to false
- closeSerialPort
- else
- sendToRadio "ID;"
- put false into gotIt
- put 0 into counter
- end if
- else
- put true into gotIt
- sendToRadio "AI0;" -- disable autostatus
-
- set lockscreen to true
- push card
- go to first card of bg "frequencies"
- sendToRadio "IF;"
- repeat until dataWaiting() Γëá false
- wait 1
- end repeat
- put getFromStack () into line
- if char 1 of line is "I" and char 2 of line is "F" then
- put char 31 of line into vfostatus
- clearradbuttons
- if vfostatus = 0 then
- set the highlight of bg button "VFO A" to true
- set the visible of bg button "Load VFO" to true
- set the visible of bg button "Memup" to false
- set the visible of bg button "MemDN" to false
- else if vfostatus = 1 then
- set the highlight of bg button "VFO B" to true
- set the visible of bg button "Load VFO" to true
- set the visible of bg button "Memup" to false
- set the visible of bg button "MemDN" to false
- else if vfostatus = 2 then
- set the highlight of bg button "Memory" to true
- set the visible of bg button "Load VFO" to false
- set the visible of bg button "Memup" to true
- set the visible of bg button "MemDN" to true
- end if
- else
- answer "got wrong data from IF" with "oops"
- end if
- pop card
- set lockscreen to false
-
- setTime
- end if
- end if
- end repeat
- end if
- end initSerialPort
-
- on clearradbuttons
- set the highlight of bg button "VFO A" to false
- set the highlight of bg button "VFO B" to false
- set the highlight of bg button "Memory" to false
- end clearradbuttons
-
-
- -- close the serial port
- on closeSerialPort
- if UsingRS232() = true then
- closeSPort
- end if
- end closeSerialPort
-
- -- send something to the radio
- on sendToRadio string
- if UsingRS232() = true then
- sendSPort string
- end if
- end sendToRadio
-
- -- get something from the radio
- on readFromRadio
- global fromRadio
-
- if UsingRS232() = true then
- -- is there data in the port?
- if charsAvailable() > 0 then
- -- yes, suck it out and stick it somewhere for processing
- put recvUpTo(empty,0,empty) after fromRadio
- end if
-
- -- the second phase. If it's a complete command (i.e. terminated
- -- with a ";") then take that part and throw it on the return
- -- stack. Have to do it this way because you might only read
- -- a partial command during one pass, so keep grabbing data until
- -- it's complete.
- put offset (";", fromRadio) into holder
- if holder > 0 then
- put char 1 to holder of fromRadio into gotBack
- addToStack gotBack
- delete char 1 to holder of fromRadio
- end if
- end if
- end readFromRadio
-
- -- functions to handle the radio data stack.
- --
- -- the global returnStack is a FIFO stack that stores a list of
- -- data items returned from the radio for processing. If there's
- -- nothing pending, it's empty.
-
- on zeroStack
- global returnStack
- put empty into returnStack
- end zeroStack
-
- on addToStack string
- global returnStack
-
- put string & return after returnStack
- end addToStack
-
- function getFromStack
- global returnStack
-
- if returnStack is empty then
- return empty
- else
- put line 1 of returnStack into string
- delete line one of returnStack
- return string
- end if
- end getFromStack
-
- function dataWaiting
- global returnStack
-
- readFromRadio
- global returnStack
-
- if returnStack is empty then
- return false
- else
- return the number of lines in returnStack
- end if
- end dataWaiting
-
- -- end of radio stack functions
-
- -- These are the functions that actually control the radio.
-
- -- lockKnob on|off (enable|disable tuning knob)
- on lockKnob value
- if value is empty then
- answer "usage: LockKnob on|off" with "okay"
- else if value is "on" then
- sendToRadio "LK1;"
- else if value is "off" then
- sendToRadio "LK0;"
- else
- answer "lockKnob: illegal value " & value with "oops"
- end if
- end lockKnob
-
- -- goUp (memory up)
- -- goDown (memory down)
- on goUp
- sendToRadio "UP;"
- end goUp
-
- on goDown
- sendToRadio "DN;"
- end goDown
-
- -- modeSelect lsb|usb|cw|fm|am|fsk
- on modeselect mode
- if mode is empty then
- answer "Usage: modeSelect lsb|usb|cw|fm|am|fsk" with "Okay"
- else if mode is "lsb" then
- sendToRadio "MD1;"
- else if mode is "usb" then
- sendToRadio "MD2;"
- else if mode is "cw" then
- sendToRadio "MD3;"
- else if mode is "fm" then
- sendToRadio "MD4;"
- else if mode is "am" then
- sendToRadio "MD5;"
- else if mode is "fsk" then
- sendToRadio "MD6;"
- else
- answer "modeSelect: illegal mode " & mode with "oops"
- end if
- end modeSelect
-
- -- vfoSelect a|b|mem
- on vfoSelect value
- if value is empty then
- answer "Usage: vfoSelect a|b|mem" with "Okay"
- else if value is "a" then
- sendtoradio "FN0;"
- else if value is "b" then
- sendToRadio "FN1;"
- else if value is "mem" then
- sendToRadio "FN2;"
- else
- answer "vfoSelect: illegal value " & value with "oops"
- end if
- end vfoSelect
-
- -- chooseMem nn (nn = 0 to 99)
- on chooseMem nn
- if nn is empty then
- answer "usage: chooseMem nn" with "okay"
- else if nn >= 0 and nn <= 99 then
- put numberformat into hold
- set numberFormat to 00
- add 0 to nn
- put "MC0" & nn & ";" into cmd
- sendToRadio cmd
- set numberformat to hold
- else
- answer "chooseMem: illegal value " & nn with "oops"
- end if
- end chooseMem
-
- -- setFreq A|B freq
- on setFreq setwhich, khz
- if setwhich is empty or khz is empty then
- answer "Usage setFreq A|B|nn khz" with "Okay"
- exit setFreq
- end if
- put the round of (khz * 1000) into khz
- set the numberformat to "00000000000"
- if setwhich is "a" then
- sendToRadio "FA" & khz & ";"
- else if setwhich is "b" then
- sendToRadio "FB" & khz & ";"
- else
- answer "setwhich: illegal value " & setwhich with "oops"
- end if
- end setFreq
-
- -- setmem nn freq mode
- -- nn is 0 - 99
- -- freq is as in setVFO
- -- mode is as in modeSelect
- on setMem nn, freq, mode
-
- if nn is empty or freq is empty or mode is empty then
- answer "usage: setmem nn, freq, mode" with "okay"
- exit setMem
- end if
-
- if nn < 0 or nn > 99 then
- answer "setmem: nn must be 0 - 99"
- exit setMem
- end if
-
- if nn <= 9 then
- put "0" & nn into nn
- end if
-
- -- converts this to a string to protect it from
- -- the upcoming numberFormat
- put nn & "" into nn
-
- if mode is empty then
- answer "setMem: mode is lsb|usb|cw|fm|am|fsk" with "Okay"
- else if mode is "lsb" then
- put "1" into modeVal
- else if mode is "usb" then
- put "2" into modeVal
- else if mode is "cw" then
- put "3" into modeVal
- else if mode is "fm" then
- put "4" into modeVal
- else if mode is "am" then
- put "5" into modeVal
- else if mode is "fsk" then
- put "6" into modeVal
- else
- answer "setMem: illegal mode " & mode with "oops"
- end if
-
- put the round of (freq * 1000) into freq
- set the numberformat to "00000000000"
-
- put "MW00" & nn & freq & modeVal & "00000;" into toRadio
- sendToRadio toRadio
-
- end setMem
-
- -- clearmem nn
- -- zap a memory
- on clearmem nn
- if nn < 0 or nn > 99 then
- answer "usage: clearmem nn"
- exit clearmem
- else
- if nn <= 9 then
- put "0" & nn into nn
- end if
-
- sendtoradio "MW00" & nn & "00000000000000000;"
- end if
- end clearmem
-
- -- getmem nn
- -- returns string "freq, mode" or empty
- function getmem nn
- if nn < 0 or nn > 99 then
- answer "usage: clearmem nn"
- exit getmem
- end if
-
- if nn <= 9 then
- put "0" & nn into nn
- end if
-
- sendToRadio "MR00" & nn & ";"
- put false into foo
- put 0 into counter
- repeat while foo is false
- add one to counter
- if datawaiting() Γëá false then
- put getFromStack() into line
- if char 1 of line Γëá "M" and char 2 of line Γëá "R" then
- answer "radio sent back something weird" & cr & line with "oops"
- return empty
- end if
- if char 5 to 6 of line Γëá nn then
- answer "radio sent back wrong memory" & cr & line with "oops"
- return empty
- end if
-
- put char 7 to 17 of line into freq
- put freq / 1000 into freq
- if freq = 0 then
- return empty
- end if
-
- put char 18 of line into mode
- if mode = 1 then
- put "LSB" into mode
- else if mode = 2 then
- put "USB" into mode
- else if mode = 3 then
- put "CW" into mode
- else if mode = 4 then
- put "FM" into mode
- else if mode = 5 then
- put "AM" into mode
- else if mode = 6 then
- put "FSK" into mode
- else
- answer "illegal mode value in getmem" with "oops"
- return empty
- end if
-
- return freq & ", " & mode
- end if
- if counter > 10 then
- return empty
- end if
- end repeat
- end getmem
-
- on turnOnRadio
- sendToRadio "PS1;"
- end turnOnRadio
-
- on turnOffRadio
- sendToRadio "PS0;"
- end turnOffRadio
-
- on setUTCTime which
- if which is empty then
- answer "usage: setUTCTime 1|2" with "okay"
- exit setUTCTime
- else if which < 1 or which > 2 then
- answer "setUTCTime: illegal value " & which with "oops"
- exit setUTCTime
- end if
- put "" & which into which -- protects from numberFormat
-
- put the seconds into now
- put bkgnd field "UTC" of card "configuration" into offset
- put offset * 60 * 60 into offset -- convert to seconds
- put now + offset into now
- convert now to dateitems
- put the numberformat into hold
- set the numberformat to "00"
- put item 4 of now into hour
- add 0 to hour
- put item 5 of now into minutes
- add 0 to minutes
- put "CK" & which & hour & minutes & "00;" into string
- sendToRadio string
- set the numberformat to hold
- end setUTCTime
-
- on setLocalTime which
- if which is empty then
- answer "usage: setLocalTime 1|2" with "okay"
- exit setLocalTime
- else if which < 1 or which > 2 then
- answer "setLocalTime: illegal value " & which with "oops"
- exit setLocalTime
- end if
- put "" & which into which -- protects from numberFormat
-
- put the seconds into now
- convert now to dateitems
- put the numberformat into hold
- set the numberformat to "00"
- put item 4 of now into hour
- add 0 to hour
- put item 5 of now into minutes
- add 0 to minutes
- put "CK" & which & hour & minutes & "00;" into string
- sendToRadio string
- set the numberformat to hold
- end setLocalTime
-
- on setTime
- if usingRS232() is true then
- if the highlight of cd button "Clock 1" ¬
- of card "configuration" is true then
- put 1 into which
- else if the highlight of cd button "Clock 2" ¬
- of card "configuration" is true then
- put 2 into which
- else
- exit setTime
- end if
- if which is 1 then
- setUTCtime 1
- setLocalTime 2
- else
- setUTCtime 2
- setLocalTime 1
- end if
- end if
- end setTime
-
- on